package br.edu.unilasalle.simon_api.rs;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;

import br.edu.unilasalle.simon_api.domain.Funcionario;
import br.edu.unilasalle.simon_api.service.IFuncionarioService;

@Path("/funcionario")
public class FuncionarioRS {
	
	@Autowired
	private IFuncionarioService service;
	
	@GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<Funcionario> findAllFuncionario() {
		return service.findAllFuncionario();
    }

    @GET
    @Path("{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Funcionario findById(@PathParam("id") long id) {
        return service.findById(id);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Funcionario create(Funcionario obj) {
        return service.save(obj);
    }

    @PUT
    @Path("{id}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Funcionario update(Funcionario obj) {
    	service.save(obj);
    	return obj;
    }

    @DELETE
    @Path("{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public void delete(@PathParam("id") long id) {
    	service.deleteById(id);
    }

}
